<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        /*伪元素清除*/
        .clearfix::before{
            content: "";
            display: block;
            height: 0;
            clear: both;
            visibility: hidden;

        }

        /*双伪元素清除*/
        .clearfix::before,.clearfix::after{
            content: "";
            display: block;
        }
        .clearfix::after{
            clear: both;
        }
        .clearfix{
            *zoom:1
        }
        header{
            border: 3px solid black;
            /*给父级设置为bfc(块级格式化上下文)*/
            overflow: hidden;
        }
        .left{
            width: 300px;
            height: 300px;
            float: left;
            background-color: yellow;
        }
        .right{
            width: 300px;
            height: 300px;
            float: right;
            background-color: #7a43b6;
        }
    </style>
</head>
<body>
<header class="clearfix">
    <div class="left "></div>
    <div class="right"></div>
<!--    额外标签清除浮动-->
<!--<div style="clear: both"></div>-->
</header>
</body>
</html>